import 'dart:convert';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:light_image/api/TestReqModel.dart';
import 'package:light_image/commom/commom.dart';
import 'package:light_image/widget/view/web_view_page.dart';

class ToolPage extends StatefulWidget {
  ToolPage({Key key, this.title}) : super(key: key);
  // This widget is the home page of your application. It is stateful, meaning
  //这个小部件是应用程序的主页。它是有状态的，意思是
  // that it has a State object (defined below) that contains fields that affect
  //它有一个State对象（定义如下），该对象包含影响
  // how it looks.
  //看起来怎么样。
  // This class is the configuration for the state. It holds the values (in this
  //这个类是状态的配置。它保存的值（在这个
  // case the title) provided by the parent (in this case the App widget) and
//case the title）由父程序（在本例中是App小部件）提供，并且
  // used by the build method of the State. Fields in a Widget subclass are
  //由状态的生成方法使用。小部件子类中的字段是
  // always marked "final".
//始终标记为“最终”
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<ToolPage> {
  @override
  void initState() {
    super.initState();
  }
  int _counter = 0;
  void _incrementCounter() {
    var url = 'https://lizhanqi.gitee.io/mysite/AppUseIndex/useindex.html';
//    'http://book.flutterj.com/'
    url = 'https://www.ixigua.com/';
    routePush(new WebViewPage(url, '未知'));
//    launch('https://github.com/ahyangnb/ncov_2019');
//    setState(() {
//      _counter++;
//    });
  }
  void loadData()async{
//    /*
//  * 获取整体统计信息
//  * */
//    Future<dynamic> getData() async {
      final Map data = await TestReqModel().data();
      setState(() {
      if (data != null && data.isNotEmpty) {
       var text=         data["appVersion"];

        print('--------------------------------------');
        print(data);
        print('--------------------------------------');
//        return TestModel.fromJson(data);
      }else{
       var a= new Image.asset('images/aaa.png',width: 500,height: 500); 
       var   text="失败咯";

      }
      });
//      return Future.value({});
//    }
  }

  //相当于xml页面构建
  @override
  Widget build(BuildContext context) {
         return  Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        MaterialButton(
          onPressed: () {
            loadData();
          },
          child: new Text("工具"),
        ),

      ],
    );

  }
}
